package com.nlina.qiniu_bigwork.controller;

import com.nlina.qiniu_bigwork.QiniuBigworkApplication;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@SpringBootTest(classes = QiniuBigworkApplication.class)
@AutoConfigureMockMvc
public class QiniuControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @Test
    @WithMockUser // 模拟一个已登录的用户
    public void testGetFileDetailsWithEmptyFileName() throws Exception {
        mockMvc.perform(get("/api/file/details")
                .param("fileName", ""))
                .andExpect(status().isBadRequest())
                .andExpect(jsonPath("$.success").value(false))
                .andExpect(jsonPath("$.message").exists());
    }
} 